<template>
  <el-dialog :visible.sync="isShow" @close="close" width="70%" class="beforeCheckDialog" :show-close='false' :closeOnClickModal='false'
    append-to-body>
    <span slot="title" class="dialog-title">
		  	添加测试{{checkTitle}}检查项
			<el-button  size="mini" @click="close" class="popupClose">关闭</el-button>
		</span>
    <el-form label-width="110px" :inline="false" class="demo-form-inline" :model="checkForm" :rules="checkRules" ref="checkForm">
      <el-form-item label="类型">
        <el-col :span="22">
          <el-input size="mini" v-model="checkType" disabled></el-input>
        </el-col>
      </el-form-item>
      <el-form-item label="检查项" prop='content'>
        <el-col :span="22">
          <el-input size="mini" placeholder="检查项" v-model="checkForm.content" ></el-input>
        </el-col>
      </el-form-item>
     </el-form>
    <span slot="footer" class="dialog-footer">
			<el-button class="penalButton" type="primary" size="mini" @click="submit">确定</el-button>
      <el-button class="penalButton" size="mini" @click="close">取消</el-button>
	  </span>
  </el-dialog>

</template>

<script>
  export default {
    props: {
      checkTitle: String,
      checkId: String,
    },
    data() {
      return {
        isShow: true,
        selectedCheck: [],
        checkForm:{checkType:0,content:""},
        checkType:"测试前检查项",
        checkRules: {
          content: [{ required: true, type: 'string', message: '请输入检查项', trigger: 'blur' },],
        },
      }
    },
    mounted() {
      //	this.form.fRef = this.checkId
      if(this.checkTitle == "前"){
        this.checkForm.checkType = 0;
        this.checkType = "测试前检查项";
      }else{
        this.checkForm.checkType = 1;
        this.checkType = "测试后检查项";
      }
    },
    methods: {
      close() {
        this.$parent.addCheckShow = false;
        this.checkForm = {checkType:0,content:""};
      },
      submit() {
        this.checkForm.fRef = this.checkId
        this.$http({
          apiUrl: '/resource/addEquipUseCheck.htm',
          method: 'post',
          params: this.checkForm,
          isJson:true
        }).then(res => {
          if (res.code == 0) {
            this.$notify({
              message: '添加成功！',
              type: 'success',
              title:"成功"
            })
            this.$parent.addCheckShow = false
            if (this.checkTitle == '前') {
              this.$parent.init()
            } else {
              this.$parent.readUsecheckList()
            }
          }
        })
      }

    }
  }

</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style >
  .beforeCheckDialog  .el-dialog {
		margin-top: 10vh !important;
		height: 80%;
	}
</style>
